package com.pet.taglib;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import org.apache.struts2.views.jsp.StrutsBodyTagSupport;
import com.pet.framework.util.StringUtil;
import com.pet.role.util.Logger;
import com.pet.system.constants.Status;

public class ParseSelect extends StrutsBodyTagSupport {
	private static final Logger logger = Logger.getLogger(ParseSelect.class);
    private String value,type,name,checkbox;

	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}
	@Override
	public int doStartTag() throws JspException {
	    try {
	    	if(StringUtil.isEmpty(name)){
	    		pageContext.getOut().write(Status.options(value, type));
	    	}else{
	    		if("1".equals(checkbox)){
		    		pageContext.getOut().write(Status.checkboxCheck(value, type, name));
	    		}else{
		    		pageContext.getOut().write(Status.radioCheck(value, type, name));
	    		}
	    	}
			
		} catch (IOException e) {
			logger.logError("adstatus tag error:"+e.getMessage());
		}
		return EVAL_BODY_BUFFERED;
	}

	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getCheckbox() {
		return checkbox;
	}
	public void setCheckbox(String checkbox) {
		this.checkbox = checkbox;
	}
	
	
	
    

}
